<!--#include file="../nav/admin_top.php" -->
<!--#include file="../nav_menu/report_top.php" -->

<div class="menuBg">
	<a class="menuReturn" href="/admin_report/index">返回所有报表</a>
  <div style="clear:both"></div>
</div>
<div class="margin20">
	<div style="padding-bottom:5px;border-bottom:1px solid #999999;" >{$rpt.name}</div>
</div>
<div class="margin10">
	<fieldset style="border: 1px solid #ccc; padding: 20px;">
		<legend style="color: green">过滤条件</legend>
		<div id="filter_bar">
			<table class="filtertb" >
				<tr>
					<td class="filtertb_l" >
						<form action="/admin_report/result" method="post" id="form1" target="result_iframe">
							<input type="hidden" id="model" name="model" value="{$rpt.model}" />
							<input type="hidden" id="action" name="action" value="{$rpt.action}" />
							<input type="hidden" id="title" name="title" value="{$rpt.name}" />
							<input type="hidden" id="downloads" name="downloads" value="1" />
							<input type="hidden" id="searchdata" name="searchdata" value="" />
							
							<table class="searchtb">
								<tr>
									<th>交易日期：</th>
									<td>
										<span>
											<select id="search_dateslt"  class="textBox" onChange="fnSearchDate()">
												<option value="0" selected="selected">所有日期</option>
												<option value="1">今天</option> 
												<option value="2">本周</option> 
												<option value="3">本月</option> 
												<option value="">自定义时间段</option> 								
											</select>
										</span>
										<span id="s_date_div" style="display:none;margin:5px auto;">
											从 <input type="text" class="textBoxDate" id="b_date" value=""   maxlength="10" />
											<input id="b_date_slt" class="btnicon_calendar" type="button">
											到
											<input type="text" class="textBoxDate" id="e_date" value=""   maxlength="10" />
											<input id="e_date_slt" class="btnicon_calendar" type="button">
										</span>	
									</td>
								</tr>
								<tr>
									<th>事务类别：</th>
									<td> 
											<?PHP
											foreach($rs_transtype as $v){ 
												echo '<label for="transtype_'.$v['id'].'"><input type="checkbox" id="transtype_'.$v['id'].'" value="'.$v['id'].'" class="transtype" checked="checked" />'.$v['name'].'('.$v['actions'].')</label> ';
											}
											?>
									</td>
								</tr>
								<tr>
									<th>会员：</th>
									<td>
									  <label for="themem_all" class="green"><input type="radio" value="1" name="themem" id="themem_all" checked="checked"  onclick="$('#xuanzemem').hide()" /> 所有会员 </label>
									  <label for="themem_slt" class="blue"><input type="radio" value="0" name="themem" id="themem_slt"  onclick="$('#xuanzemem').show()"  /> 指定会员 </label>
									</td>
								</tr> 
								<tr id="xuanzemem" style="display:none">
									<th>选择指定会员：</th>
									<td> 
										<span id="slt_user_span"> </span>
										<span id="del_user_span" style="display:none"><a href="javascript:void(0)"  onclick="fnDelUser()">清除</a> 或 </span>
										<a href="javascript:void(0)" id="slt_user_a"  onclick="fnGetUser()" title="请点击选择">选择会员</a>
										<input type="hidden" id="user_id" name="user_id" value="" />
									</td>
								</tr>
							</table>
						</form>
					</td>
					<td class="filtertb_r">
						<button onclick="fnView()">预览</button>
						<button onclick="fnExport()" style="margin-left:20px">导出报表 </button>
					</td>
				</tr>
			</table>
		</div>
	</fieldset>				
</div>
<div class="report_outer">
	<div id="result_div">
		<iframe id="result_iframe" name="result_iframe" style="width:950px;height:450px;border:1px dashed #CCCCCC;"></iframe>
	</div>
</div>
<script type="text/javascript">
$().ready(function(){
	o2js.build('jscalendar');
	o2js.build('dates');
	fnSetSltDate('b_date','b_date_slt');
	fnSetSltDate('e_date','e_date_slt');
	fnSearchDate();
});




function fnDelUser(){
	$('#user_id').val('');
	$('#slt_user_span').html(' ');
	$('#slt_user_a').html('选择会员');
	$('#del_user_span').hide();
}
/* 选择会员 */
function fnGetUser(){
	GfnSelectUser('onFnGetUser','选择会员');
}
function onFnGetUser(e){
  $('#user_id').val('');
	$('#slt_user_span').html(' ');
	var html = [];
	var ids  = [];
	for(var i=0; i<e.user_ids.length ; i++){
		html.push('('+e.user_ids[i].username+')'+e.user_ids[i].name);
		ids.push(e.user_ids[i].id);
	}
  $('#user_id').val(ids.join(','));
	$('#slt_user_span').html(html.join(' , '));
	$('#slt_user_a').html('更换会员');
	$('#del_user_span').show(); 
} 






function fnSearchDate(){
	$('#s_date_div').hide();
	var date = new Date();
	switch($('#search_dateslt').val()){
		case "0"://  
			$('#b_date').val('');
			$('#e_date').val('');
			break;
		case "1"://  
			$('#b_date').val(today());
			$('#e_date').val(today());
			break;
		case "2":// 
			var b = getWeekFirst(date).eformat('yyyy-MM-dd');
			var e = getWeekLast(date).eformat('yyyy-MM-dd'); 
			$('#b_date').val(b);
			$('#e_date').val(e);
			break;
		case "3"://本月
			var b = getMonthFirst(date).eformat('yyyy-MM-dd');
			var e = getMonthLast(date).eformat('yyyy-MM-dd'); 
			$('#b_date').val(b);
			$('#e_date').val(e);
			break;
		default:
			$('#s_date_div').show();
			break;
	}
}
function fnGetSearchData(){
	var transtype = [];
	var ids = '';
	$('.transtype').each(function(){
		if($(this).attr('checked')){
			transtype.push($(this).val());
		}
	}); 
	if(transtype.length <= 0){
		alert('请至少选择一个 事务类别');
		return false;
	}
	
	if($('#themem_slt').attr('checked')){
		//判断有没有选择会员
		if($('#user_id').val() == ''){
			alert('请至少选择一个 会员');
			return false;
		}
		ids = $('#user_id').val();
	}
	
	
	var ret={
		b_date:$('#b_date').val(),
		e_date:$('#e_date').val(),
		transtype:transtype.join(','),
		ids:ids
	};
	return JSON.encode(ret);
}
</script>
<!--#include file="../nav/admin_bottom.php" -->